# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :file_assert.py
# @Time      :2023/11/10 14:26
# @Author    :WangXiang

from utils.settting import ensure_path_sep
import os
def compare_txt_files(file1, file2):
    print("====:", file1)
    print("====:", file2)
    with open(file1, 'r') as f1, open(file2, 'r') as f2:
        lines1 = f1.readlines()
        lines2 = f2.readlines()

        if len(lines1) != len(lines2):
            return False

        for line1, line2 in zip(lines1, lines2):
            if line1 != line2:
                return False

        return True


# 比较两个文件的内容
file1_path = ensure_path_sep("/file-size/600_text.txt")  # 源文件
folder_path = "D:\\600\\20231112090136629"
for root, dirs, files in os.walk(folder_path):
    for file in files:
        file_path = os.path.join(root, file)
        print(file_path)
        # file_path = "D:\\PDF\\20231110142424526\\500_text.txt"   # 下载后的文件
        result = compare_txt_files(file1_path, file_path)

        if result:
            print("两个文件的内容一致")
        else:
            print("两个文件的内容不一致")